package com.xlh.service;

import com.xlh.domain.Product;
//import com.xlh.service.fallback.ProductServiceFallBackFactory;
//import com.xlh.service.fallback.ProductServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(
        value = "service-product"
        //,
        //fallback = ProductServiceFallback.class,
        //fallbackFactory = ProductServiceFallBackFactory.class
        )//声明调用的提供者的name
//fallback用于指定容错类
public interface ProductService {
  //指定调用提供者的哪个方法
  //@FeignClient+@GetMapping

  //就是一个完整的请求路径 http://service-product/product/{pid}
  @GetMapping(value = "/product/{pid}")
  Product findByPid(@PathVariable("pid") Integer pid);
  //扣减库存
  //参数一: 商品标识
  //参数二:扣减数量
  @RequestMapping("/product/reduceInventory")
  //Feign远程调用 多个参数要加@RequestParam 注解
  void reduceInventory(@RequestParam("pid") Integer pid,
                       @RequestParam("number") Integer number);
}

